
// #ifndef VUE3
import Vue from 'vue'
import App from './App'

//自己創建的vuex模块共享數據
import store from '@/store/store.js'
import {$http} from '@escook/request-miniprogram'

//把导入的http包挂載到顶层的http中
uni.$http = $http
//根路徑
$http.baseUrl = 'https://farm-app-backend-1841150-1311299937.ap-shanghai.run.tcloudbase.com/'
//$http.baseUrl = 'http://localhost:5000/'

//弹框
uni.$showMessage = function(title = '找不到数据!', duration = 1000) {
  uni.showToast({
    title,
    duration,
    icon: 'none'
  })
}

//設置拦截器显示加載效果
$http.beforeRequest = function(options){
  uni.showLoading({
    title:"疯狂加載中..."
  })
  //判斷請求是否為有权限接口
  if(options.url.indexOf('/mine/') !== -1){
    options.header = {
      Authorization:store.state.user.token
    }
  }
}
$http.afterRequest = function(){
  uni.hideLoading()
}


Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App,
    store
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif